/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * Entidade RotaHasCompania
 */
@Entity
@Table(name = "rota_has_compania", catalog = "agenciadeviagem", schema = "")
@NamedQueries(
    {
        @NamedQuery(name = "RotaHasCompania.findAll", query = "SELECT r FROM RotaHasCompania r"),
        @NamedQuery(name = "RotaHasCompania.findById", query = "SELECT r FROM RotaHasCompania r WHERE r.id = :id"),
        @NamedQuery(name = "RotaHasCompania.findCompanias", query = "SELECT r FROM RotaHasCompania r WHERE r.rotanome = :rotanome"),
        @NamedQuery(name = "RotaHasCompania.findAllRotas", query = "SELECT r FROM RotaHasCompania r WHERE r.companianome = :companianome"),
        @NamedQuery(name = "RotaHasCompania.DeletaRotasDaCompania", query = "Delete FROM RotaHasCompania r WHERE r.companianome = :companianome")
    }
)
public class RotaHasCompania implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @JoinColumn(name = "Rota_nome", referencedColumnName = "nome", nullable = false)
    @ManyToOne(optional = false)
    private Rota rotanome;
    @JoinColumn(name = "Compania_nome", referencedColumnName = "nome", nullable = false)
    @ManyToOne(optional = false)
    private Compania companianome;

    /**
     * Construtor Default
     */
    public RotaHasCompania() {
    }

    /**
     *
     * @param id
     */
    public RotaHasCompania(Integer id) {
        this.id = id;
    }


    /**
     *
     * @return Integer
     */
    public Integer getId() {
        return id;
    }

    /**
     *
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     *
     * @return Rota
     */
    public Rota getRotanome() {
        return rotanome;
    }

    /**
     *
     * @param rotanome
     */
    public void setRotanome(Rota rotanome) {
        this.rotanome = rotanome;
    }

    /**
     *
     * @return Compania
     */
    public Compania getCompanianome() {
        return companianome;
    }

    /**
     *
     * @param companianome
     */
    public void setCompanianome(Compania companianome) {
        this.companianome = companianome;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RotaHasCompania)) {
            return false;
        }
        RotaHasCompania other = (RotaHasCompania) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.RotaHasCompania[id=" + id + "]";
    }

}
